package com.masterclient.app.modules.goods.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.R;
import com.masterclient.app.modules.bridge.TaskRetainBean;

public class TaskRetainRecyclerAdapter extends BaseQuickAdapter<TaskRetainBean.DataBean.RewardItems, BaseViewHolder> {

    public TaskRetainRecyclerAdapter() {
        super(R.layout.item_task_retain);
    }

    @Override
    protected void convert(BaseViewHolder helper, TaskRetainBean.DataBean.RewardItems item) {
        TextView signTitle = helper.getView(R.id.sign_title);
        View viewCoupon = helper.getView(R.id.view_coupon);
        View viewGzgCoin = helper.getView(R.id.view_gzg_coin);
        TextView tvGzgCoin = helper.getView(R.id.tv_gzg_coin);
        View viewGoldCoin = helper.getView(R.id.view_gold_coin);
        TextView tvGoldCoin = helper.getView(R.id.tv_gold_coin);
        TextView tvTipText = helper.getView(R.id.tv_tip_text);

        signTitle.setText(item.missionText);
        if ("5".equals(item.type)){
            //金币抽奖任务
            if (!TextUtils.isEmpty(item.coupon)) {
                tvTipText.setVisibility(View.VISIBLE);
                tvTipText.setText(item.coupon);
            } else {
                tvTipText.setVisibility(View.GONE);
            }
            viewCoupon.setVisibility(View.GONE);
        }else {
            ////其他任务
            if (!TextUtils.isEmpty(item.coupon)) {
                viewCoupon.setVisibility(View.VISIBLE);
            } else {
                viewCoupon.setVisibility(View.GONE);
            }
            tvTipText.setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(item.bupiao) && Double.parseDouble(item.bupiao) > 0) {
            viewGzgCoin.setVisibility(View.VISIBLE);
            tvGzgCoin.setText(item.bupiao);
        } else {
            viewGzgCoin.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(item.integral) && Double.parseDouble(item.integral) > 0) {
            viewGoldCoin.setVisibility(View.VISIBLE);
            tvGoldCoin.setText(item.integral);
        } else {
            viewGoldCoin.setVisibility(View.GONE);
        }

    }
}
